package com.ruoyi.common.exception;

import org.springframework.http.HttpStatus;

/**
 * @author Fan Xiao Gang.
 * @ClassName RequestException
 * @Description TOD0
 * @Date 2023/6/29
 */
public class RequestException extends RuntimeException{
    public static final int DEFAULT_ERROR_CODE = HttpStatus.INTERNAL_SERVER_ERROR.value();
    private int code = DEFAULT_ERROR_CODE;
    public RequestException(String message) {
        super(message);
    }
    public RequestException(int code) {
        this.code = code;
    }
    public RequestException(String message, int code) {
        super(message);
        this.code = code;
    }
    public RequestException(String message, Throwable cause, int code) {
        super(message, cause);
        this.code = code;
    }
    public RequestException(Throwable cause, int code) {
        super(cause);
        this.code = code;
    }
    public RequestException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, int code) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = code;
    }
    public int getCode() {
        return code;
    }
    public RequestException setCode(int code) {
        this.code = code;
        return this;
    }
}
